package com.zoweunion.mechanic.dao.base;

import com.zoweunion.mechanic.entity.CarListBean;
import com.zoweunion.mechanic.entity.FacilitatorEntity;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

@Mapper
@Component
public interface OwnerDao {

	/**
	 * 插入车辆表
	 * @param reqMap
	 * @return
	 */
	int addCar(Map<String, Object> reqMap);

	/**
	 * 插入车主_车辆关联表
	 * @param reqMap
	 * @return
	 */
	int addOwnerCar(Map<String, Object> reqMap);

	/**
	 * 插入车辆照片表
	 * @param mapList
	 * @return
	 */
	int addOwnerCarImg(@Param("mapList") List<Map<String, Object>> mapList);

	/**
	 * 根据车辆id查询车辆信息
	 */
	Map<String, Object> getCarInfoById(Map<String, Object> reqMap);
	
	
	/**
	 * 编辑车辆信息
	 * @param reqMap
	 * @return
	 */
	int editCar(Map<String, Object> reqMap);

	/**
	 * 删除车主车辆关联数据
	 * @param reqMap 车辆id
	 * @return
	 */
	int deleteOwnerCar(Map<String, Object> reqMap);

	/**
	 * 根据车辆id 查询本服务商所有的绑定信息
	 * @param reqMap
	 * @return
	 */
	List<Map<String, Object>> getOwnerCarByCarId(Map<String, Object> reqMap);

	/**
	 * 删除车辆信息 
	 * @param reqMap 车辆id
	 * @return
	 */
	int deleteCar(Map<String, Object> reqMap);
	
	/**
	 * sType == 1\2\3 主机厂、服务商
	 * @param reqMap s_id,r_id currentPage pageSize (车主姓名 手机号)
	 * @return 车主分页列表
	 */
	List<Map<String, Object>> pageQuery(Map<String, Object> reqMap);

	/**
	 * sType == 4 金融平台
	 * @param reqMap s_id,r_id currentPage pageSize (车主姓名 手机号)
	 * @return 车主分页列表
	 */
	List<Map<String, Object>> pageQueryByBanking(Map<String, Object> reqMap);


	/**
	 * 根据条件查询车主总条数
	 * @param reqMap
	 * @return
	 */
	int countOwner(Map<String, Object> reqMap);

	/**
	 * 根据条件查询金融平台车主总条数
	 * @param reqMap
	 * @return
	 */
	int countOwnerByBanking(Map<String, Object> reqMap);

	/**
	 * @param id 车主id
	 * @return 该车主拥有车数量
	 */
	int countCarsByOid(String id);

	
	/**
	 * 通过车主id查询车辆列表 和司机信息
	 * @param reqMap id  车主id
	 * @return
	 */
	List<Map<String, Object>> getCarsByOid(Map<String, Object> reqMap);
	
	
	/**
	 * 未绑定的物联网卡分页查询列表
	 * @return
	 */
	List<Map<String, Object>> getUnbindThingsList(Map<String, Object> reqMap);

	/**
	 * 查询未绑定的物联网卡数量
	 */
	int CountUnbindThings(Map<String, Object> reqMap);

	/**
	 * 查询物联网卡是否被绑定
	 */
	Map<String, Object> selectThingsIdIsBind(Map<String, Object> reqMap);

	/**
	 * 更新物联网卡
	 * @param reqMap
	 * @return
	 */
	int updateThings(Map<String, Object> reqMap);

	/**
	 * 删除车主
	 * @param reqMap
	 * @return
	 */
	int deleteOwner(Map<String, Object> reqMap);

	/**
	 * 根据s_id查询所有车辆
	 * @param reqMap
	 * @return
	 */
	List<Map<String, Object>> getCarsBySId(Map<String, Object> reqMap);

	/**
	 * 根据s_id查询所有车辆 分页
	 * @param reqMap
	 * @return
	 */
	List<Map<String, Object>> getCarsBySIdPage(Map<String, Object> reqMap);

	/**
	 * 根据s_id查询所有车辆 分页
	 * @param reqMap
	 * @return
	 */
	List<Map<String, Object>> getCarsByBankingIdPage(Map<String, Object> reqMap);

	/**
	 * 根据s_id查询所服务商
	 * @param reqMap
	 * @return
	 */
	List<Map<String, Object>> getCarsByBankingIdPageForServerList(Map<String, Object> reqMap);

	/**
	 * 根据s_id查询所有车辆 总数量
	 * @param reqMap
	 * @return
	 */
	int getCarsBySIdCount(Map<String, Object> reqMap);

	/**
	 * 根据金融平台id查询所有车辆 总数量
	 * @param reqMap
	 * @return
	 */
	int getCarsCountByBankingId(Map<String, Object> reqMap);

	List<Map<String, Object>> getCarsListBySId(Map<String, Object> reqMap);


	List<Map<String, Object>> getCars(Map<String, Object> map);

	List<Map<String, Object>> getCarsBySid(Map<String, Object> map);
	
	List<Map<String,Object>> getCarHistory(Map<String, Object> map);
	
	int createCarHistory(Map<String, Object> map);
	
	int updateCarHistory(Map<String, Object> map);

	String getCarInfoByCarId(@Param("carId") String carId);

	int selectThingsId(@Param("thingsId")String thingsId);

	Map<String, Object> getCarTypeById(@Param("id") String carTypeId, @Param("tableType")String tableType);


    List<Map<String, Object>> getEngineNameList();

    void insertExcavator(@Param("thingsId")String thingsId);

	void updateExcavator(@Param("thingsId")String thingsId);

    List<Map<String, Object>> getOwnerList(Map<String, Object> reqMap);

    List<Map<String, Object>> getCarsByOidNew(Map<String, Object> reqMap);

	List<Map<String, Object>> getCarsByOidNewOfSubService(Map<String, Object> reqMap);

    int getExcavator(String things_id);

    String getTypeIdByBrandId(Map<String, Object> reqMap);

    String getBrandParentIdByBrandId(Map<String, Object> reqMap);

    String getTypeByBrandId(Map<String, Object> reqMap);


    String getFirstBySid(Map<String, Object> reqMap);

    void updateCarInfoById(Map<String, Object> reqMap);

    List<CarListBean> carsListExport(Map<String, Object> reqMap);

    String getServerName(Map<String, Object> reqMap);

    //通过车主id逻辑删除owner表中车主与车辆的关联
    void updateCarByOwner(String id);

    List<FacilitatorEntity> getFacilitatorList(Map<String, Object> reqMap);

	int applyAccountingPeriod(Map<String, Object> reqMap);

	int addApplyAccountingPeriodRecord(Map<String, Object> reqMap);

	int selectApplyAccountingPeriod(Map<String, Object> reqMap);

	Map<String, Object> selectAccountingPeriodInfo(Map<String, Object> reqMap);

	int updateAccountingPeriod(Map<String, Object> reqMap);

	List<Map<String, Object>> selectApplyAccountingPeriodRecord(Map<String, Object> reqMap);

	void insertRepaymentStatement(Map<String, Object> reqMap);

	void deleteRepaymentStatement(Map<String, Object> reqMap);

	Map<String, Object> selectRepaymentStatementInfo(Map<String, Object> reqMap);

	List<Map<String, Object>> selectRepaymentStatement(Map<String, Object> reqMap);

	void updateRepaymentStatement(Map<String, Object> reqMap);

	List<Map<String, Object>> selectAllNoRepaymentStatement();

	List<Map<String, Object>> selectAllNoRepaymentStatementByDay(int day);

	Map<String, Object> selectDelayRepayLatestInfo(Map<String, Object> reqMap);
}
